﻿$pwd = pwd
$sn_exe = "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\x64\sn.exe"
$pkgDir = [System.IO.DirectoryInfo]::new([System.IO.Path]::Combine($pwd, '../pkg')).FullName

$projectNameList =
	"{要进行编译打包的项目名称}"

$now=Get-Date
$startDate =  [System.DateTime]::ParseExact("2018-05-21","yyyy-MM-dd",[System.Globalization.CultureInfo]::InvariantCulture) # Date("2018-05-21")
$elapsed = $now - $startDate
$version = "1.0.{0}.{1}" -f ($elapsed.Days, ($elapsed.Hours * 60 + $elapsed.Minutes))

ForEach($projectName in $projectNameList) {
	$project = [System.IO.DirectoryInfo]::new([System.IO.Path]::Combine($pwd, $projectName, $projectName+".csproj")).FullName  

	# 编译文件
	dotnet build --configuration=Release -f netstandard2.0 --version-suffix=$version $project
	#dotnet build --configuration=Release -f net461 --version-suffix=$version $project

	# dotnet打包
	dotnet pack --configuration=Release --no-build --version-suffix=$version --output=$pkgDir $project
}

# 将打包的程序发送到服务器
ForEach($projectName in $projectNameList) {
	$pkgFile = [System.IO.Path]::Combine($pkgDir, "{0}.{1}.nupkg" -f ($projectName, $version))
	dotnet nuget push $pkgFile --source=http://{nuget服务器域名} --api-key={部署的nuget服务程序配置文件设置的apiKey}
}
pause